Skip to content

Implement e2e tests for export functionality#3506

Open
DuBento wants to merge 31 commits intothought-machine:masterfrom
DuBento:export-tests
Open

Implement e2e tests for export functionality#3506
DuBento wants to merge 31 commits intothought-machine:masterfrom
DuBento:export-tests

Conversation

@DuBento
Copy link
Copy Markdown

@DuBento DuBento commented Mar 24, 2026

This changes introduce small, targeted export test cases. The goal is to use these test for validating upcoming changes to the export logic.

  • Introduced a new please_export_e2e_test build def that is heavily inspired by please_repo_e2e_test but branches away to avoid injecting any base configuration files.
  • Favoured readability by using golden-master tests: for each case we define a test_repo and an expected_repo with the entire files for testing and for validating the export.
  • Non-breaking changes to the generic please_repo_e2e_test were added to accommodate additional logic.

Copy link
Copy Markdown
Contributor

@toastwaffle toastwaffle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's ensure that each test repo has at least one target that does not get exported (getting it as close as possible to the edge of being exported). You've got quite a few cases here where the expected repo is identical to the test repo, which doesn't prove anything for the "export as little as possible" goal of exporting. Bonus points for making the e2e enforce that the test repo and expected repo are different.

Also, what's the behaviour around comments in BUILD files - is it worth a test case which exposes that?

# Golden-Master validation with expected repo. Done before any building to avoid plz-out
f'diff -r "{exported_repo}" "$DATA_EXPECTED_REPO"',
# Tests building the exported target which in turn ensures the sources are included
f'plz {config_override} --repo_root="{exported_repo}" build {targets}',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense for this to just be plz build //...? Each repo should be tiny, so building everything shouldn't be a problem, and it asserts our requirement that the entire export should be buildable?


# Export a target generated by a native genrule target and trim unused
# build statements.
please_export_e2e_test(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please could you move each of these please_export_e2e_test targets to a BUILD file alongside the test/expected repos?

@@ -0,0 +1,5 @@
filegroup(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either this should contain an entry for dummy.build_defs, or dummy.build_defs shouldn't exist

please_export_e2e_test(
name = "export_standard_children_custom_target",
cmd_on_export = [
# Child of build def
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's avoid referring to children, as that's not well-defined terminology. adjacent_targets_in_build_def is probably better naming for this case, and the fact that one is a "child" of the other doesn't make a difference.

What you're essentially capturing here is that a target A created in a build def alongside the target B that we're trying to export will result in both A and B being buildable


# # Test go binary target.
please_export_e2e_test(
name = "export_go_binary",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the target being exported moving to a subdirectory, I don't see any behavioural difference between this and export_go_target_with_go_dep

)

# Test outputs export.
please_repo_e2e_test(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you not use please_export_e2e_test here? I think both would be clearer as golden-master tests

)

# Export a target from a repo that preloads a build def.
# This test purposely doesn't use the custom def but checks that the source files are still included.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# This test purposely doesn't use the custom def but checks that the source files are still included.
# The exported target doesn't use the preloaded build def, but the preloaded build def is still present in the export.

testing repos that include Go targets.
"""
EXPORT_DIR = "plz-out/plzexport"
test_repo = f"{dir}/test_repo"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can we call this source_repo rather than test_repo throughout please

config_override = ""
if include_go:
config_override += "-o plugin.go.gotool:$TOOLS_GO"
tools["GO"] = [CONFIG.GO.GO_TOOL]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this necessary at all?


config_override = ""
if include_go:
config_override += "-o plugin.go.gotool:$TOOLS_GO"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can't we just put this in the .plzconfig in the source repo?

goddenrich and others added 6 commits March 27, 2026 20:01
Previously for every file we were looping through every target in the
graph O(NxM). Now we first build a map of targets for each file for the
whole graph then loop through the files to output the labels O(N+M).
This vastly improves the performance of plz query what inputs for a
large graph and large number of files.
I think this might be required before trying to upgrade the golang
version in please repository, (thought-machine#3498) to enable CircleCI setup to run
tests properly

Co-authored-by: roselyn <roselyn@thoughtmachine.net>
…ne#3502)

```
str.ljust(width[, fillchar])
str.rjust(width[, fillchar])
```

These methods are equivalent to their Python namesakes: they return a
copy of the string left-padded or right-padded with the character given
by `fillchar` until it is `width` characters long. `fillchar` defaults
to `' '` (i.e. a space).
…#3504)

`str.ljust` should left-justify `str` in the return value, and
`str.rjust` should right-justify `str` in the return value - in other
words, `str.ljust` should right-pad `str`, and `str.rjust` should
left-pad `str`.
chrisnovakovic and others added 3 commits March 27, 2026 20:01
…machine#3507)

The v1.1 endpoint (`/api/v1.1/project/github/...`) is deprecated. Switch
to the v2 pipeline endpoint (`/api/v2/project/gh/.../pipeline`) which
uses header-based auth and triggers the full pipeline.
We still have a glut of CircleCI credit to spend...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants